package ko.util;

import java.util.ArrayList;
import java.util.Hashtable;

public class KTweenObj {
	public Object scope					;
	public Hashtable<String, KPropertyInfoObj> properties;

	public float timeStart					;	// Time when this tweening should start
	public float timeComplete				;	// Time when this tweening should end
	
	public Boolean useFrames				;	// Whether or not to use frames instead of time
	
	public IFunction transition				;	// Equation to control the transition animation
	public TransitionParam transitionParams			;	// Additional parameters for the transition
	
	public Boolean isPaused					;	// Whether or not this tween is paused
	public float timePaused					;	// Time when this tween was paused
	public Boolean isCaller					;	// Whether or not this tween is a "caller" tween
	public float timesCalled				;	// How many times the caller has already been called ("caller" tweens only)
	public Boolean waitFrames				;	// Whether or not this caller should wait at least one frame for each call execution ("caller" tweens only)
	public float skipUpdates				;	// How many updates should be skipped (default = 0; 1 = update-skip-update-skip...)
	public float updatesSkipped				;	// How many updates have already been skipped
	public Boolean hasStarted				;	// Whether or not this tween has already started
	
	public IFunction onComplete				;	// Function to be executed on the object when the tween completes (once)
	public Object onCompleteScope			;	// Scope in which the event function is ran
	public ArrayList<Object> onCompleteParams;		// Array of parameters to be passed for the event
	
	public KTweenObj(Object p_scope, float p_timeStart, float p_timeComplete, Boolean p_useFrames, 
			IFunction p_transition, TransitionParam p_transitionParams) {
		scope				=	p_scope;
		timeStart			=	p_timeStart;
		timeComplete		=	p_timeComplete;
		useFrames			=	p_useFrames;
		transition			=	p_transition;
		transitionParams	=	p_transitionParams;

		properties		=	new Hashtable<String, KPropertyInfoObj>();
		isPaused		=	false;
	}

	public static Hashtable<String, Object> makePropertiesChain(Object... p_parameters) {
		Hashtable<String, Object> ht = new Hashtable<String, Object>();
		for (int i = 0; i < p_parameters.length;i+=2) {
			ht.put(p_parameters[i].toString(), p_parameters[i + 1]);
		}
		return ht;
	}
}
